<template>
	<!-- 联系我们 -->
	<div>
		<div style="padding:10px; line-height:50rpx; line-height: 60rpx;">
			<div>店铺名：{{ shopInfo.name }}</div>
			<div v-for="(phone, index) in shopInfo.phoneList" :key="index">
				<div @tap="callPhone(phone)">联系电话{{ index + 1 }}: {{ phone }}</div>
			</div>
			<div>营业时间段：{{ shopInfo.startTime }}-{{ shopInfo.endTime }}</div>
			<div @tap="setClipboardData(shopInfo.relationQQ)">联系QQ: {{ shopInfo.relationQQ }}</div>
			<div @tap="setClipboardData(shopInfo.relationWeixin)">联系微信: {{ shopInfo.relationWeixin }}</div>
			<div>店铺地址: {{ shopInfo.address }}</div>
		</div>
	</div>
</template>

<script>
import { getShopInfo } from '@/api/shopApi.js';
export default {
	data() {
		return {
			shopInfo: {
				name: "",
				phoneList: [],
				startTime: "",
				endTime: "",
				relationQQ: "",
				relationWeixin: "",
				address: "",
			}
		};
	},
	mounted() {
		getShopInfo({
			success: res => {
				this.shopInfo = res.data;
				this.shopInfo.phoneList = this.shopInfo.relationPhones.split(',');
			}
		});
	},
	methods: {
		// 拨打电话
		callPhone(phone) {
			uni.setClipboardData({
				data: '' + phone,
				success: function() {
					uni.makePhoneCall({
						phoneNumber: '' + phone // 坑，纯数字就不行
					});
				}
			});
		},
		// 负责内容到剪切板
		setClipboardData(data) {
			uni.setClipboardData({
				data: '' + data, // 必须是字符串
				success: function() {}
			});
		}
	}
};
</script>

<style></style>
